package com.travel.utils;

import com.travel.pojo.tourist_demand.Address;
import org.apache.commons.beanutils.BeanComparator;
import org.apache.commons.collections.comparators.ComparatorChain;
import java.util.Collections;
import java.util.List;

public class SortUtil {

    /**
     * 集合排序工具类
     * @param list 集合排序对象
     * 使用对象中starttime字段进行排序
     */
    @SuppressWarnings("unchecked")
    public static void sortByWhat(List<Address> list){
        try{
            ComparatorChain moInfoComparator = new ComparatorChain();
            moInfoComparator.addComparator(new BeanComparator("starttime"));
            Collections.sort(list, moInfoComparator);
        } catch (Exception e) {

        }
    }

}
